<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@page import="java.util.Random"%>
<!-- saved from url=(0029)http://cdxurui.com/Login.aspx -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Console</title>
<LINK href="${pageContext.request.contextPath }/css/main_style.css" type=text/css rel=stylesheet>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-1.3.2.js"></script>
<style type="text/css">
.login_label {
	text-align: right;
	height: 25px;
	width: 30%;
	font-family:'lucida grande',helvetica,verdana,arial,sans-serif;
	font-size:12px;
}

.lobin_title {
	font-family:'lucida grande',helvetica,verdana,arial,sans-serif;
	height: 35px;
	font-weight: bold;
	Font-style: oblique;
	font-size:12px;
}

a{
	font-family:'lucida grande',helvetica,verdana,arial,sans-serif;
	font-size:12px;
}
</style>
<script type="text/javascript">
function changeImage(_obj){
	  	var path='<%=request.getContextPath()%>';
		var random = Math.random(1000);
		_obj.src=path+"/AuthImage?random="+random;
	  }
function submitLogin(){
	var path='<%=request.getContextPath()%>';
	var username = document.getElementById("TxtUserName").value;
	var password = document.getElementById("TxtPassword").value;
	var validateCode = document.getElementById("validateCode").value; 
	if(username==""){
		alert("请输入用户名!");
		return;
	}
	if(password==""){
		alert("请输入密码!");
		return;
	}
	if(validateCode==""){
		alert("请输入验证码!");
		return;
	}
	$.ajax({
        type: "GET",
        url: path + "/login.htm?username=" + username+"&password="+password+"&validateCode="+validateCode,
        dataType: "txt",
        success: function(returnMsg){
			if(returnMsg!=""){
			returnMsg =returnMsg.split("-");
				if(returnMsg[0]!="success"){
					alert(returnMsg[1]);
					var vcode = document.getElementById("imageAuth");
					changeImage(vcode);
				}else{
					//alert("登录成功");
					window.location.href =path+"/manager.htm";
				}
			}
        },
        error: function(){
            alert("服务器繁忙,请稍后重试!");
        }
    });
}

</script>
</head>
<body>
	<form name="login_form" method="post"
		>

		<div id="login_body">
			<div id="login_div">
				<table border="0" width="100%">

					<tbody>
						<tr>
							<td class="login_label">帐号：</td>
							<td><input name="txtName" type="text" id="TxtUserName"
								class="Account" style="width: 150px;"></td>
						</tr>
						<tr>
							<td class="login_label">密码：</td>
							<td><input name="txtPassword" type="password"
								id="TxtPassword" class="Password" style="width: 150px;">
							</td>
						</tr>
						<tr>
							<td class="login_label">验证码：</td>
							<td><input name="txtCode" type="text" id="validateCode"
								class="ValidCode" style="width: 69px;">
								<img id="imageAuth" src="<%=request.getContextPath() %>/AuthImage?random=<%= new Random(1000).nextFloat() %>" onclick="changeImage(this)" alt="看不清楚？点击换一张" />
								</td>
						</tr>
						<tr>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td></td>
							<td>
								<input type="button" name="btn_login" value="登录" id="btn_login" class="submit" onclick='submitLogin();'>
			                        &nbsp;&nbsp;
			                    <input type="reset" value="重置" class="submit">
						</tr>
						<tr>
							<td class="login_label"></td>
							<td><span id="lblMsg" style="color: Red;"></span></td>
						</tr>
						<tr>
							<td></td>
							<td>
								<a id="link_android"href="<%=request.getContextPath() %>/server.apk" target="_blank">Apk下载</a>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</form>

</body>
</html>
